package com.contory.ssn_lgnd.app.maingame;

import java.util.LinkedList;

import android.util.Log;

import com.contory.ssn_lgnd.app.comp.UpdatePtr;

public class EventGroup implements UpdatePtr{
	LinkedList<EventSocket> eventList;
	byte state = 0;
	
	public EventGroup(){
		eventList = new LinkedList<EventSocket>();
	}
	
	public void addEvent(EventObjectPtr eventObj){
		eventList.add(new EventSocket(eventObj));
	}
	
	public void excute(){
		for(int i = 0; i < eventList.size(); i++){
			eventList.get(i).excute();
		}
		state = 1;
	}

	public void clear(){
		eventList.clear();
	}
	
	public boolean getEndBool(){
		if(state == 2)
			return true;
		return false;
	}
	
	@Override
	public void update(float deltaTime) {
		switch(state){
			case 0:
			break;
			
			case 1:
			for(int i = 0; i < eventList.size(); i++){
				eventList.get(i).update(deltaTime);
				if(eventList.get(i).getEndBool()){
					eventList.remove(eventList.get(i));
				}
			}
			if(eventList.size() == 0){
				state = 2;
			}
			break;
			
			case 2:
			break;
		}
	}
}
